import React from 'react';
import moment from "moment";

export default class postbody extends React.Component {
  constructor(props) {
    super(props);
  }

  changeDate(date) {
     return moment(date).format('YYYY-MM-DD hh:mm');
  }

  render() {
    if(this.props.data!=null)
      return (
        <tbody className="thw">
        {
        	this.props.data.map((res,index)=>(
        		<tr key={index}>
        			<th colSpan="3"><a href={"post?id="+res.id}>{res.posttitle}</a></th>
        			<td>{res.categoryName}</td>
        			<td>{res.postAuthor}</td>
        			<td>{res.replynum+"/"+res.readnum}</td>
        			<td>{this.changeDate(res.createTime)}</td>
        		</tr>
        	))
        }
        </tbody>
      );
    else
      return (<tbody className="thw"><tr><td colSpan="6" align="center" className="red">该板块还没有发帖记录</td></tr></tbody>);
  }
}